import Cookies from "js-cookie"

/**
 *  token在缓存中的键名
 * @type {string}
 */
const TOKEN_KEY = "adminToken"

/**
 * 缓存token
 * @param token 后端的token
 * @returns {*}
 */
export function setToken(token) {
    return Cookies.set(TOKEN_KEY, token)
}

/**
 *  获取Cookies中的token
 * @returns {*}
 */
export function getToken() {
    return Cookies.get(TOKEN_KEY)
}

/**
 * 删除Cookies中的token
 * @returns {*}
 */
export function removeToken() {
    return Cookies.remove(TOKEN_KEY)
}

const ACCOUNT_INFO = "accountInfo"

export function setAccountInfo(accountInfo) {
    return Cookies.set(ACCOUNT_INFO, accountInfo)
}

/**
 *  获取Cookies中的token
 * @returns {*}
 */
export function getAccountInfo() {
    return Cookies.get(ACCOUNT_INFO) ? Cookies.get(ACCOUNT_INFO) : '{}'
}

/**
 * 删除Cookies中的token
 * @returns {*}
 */
export function removeAccountInfo() {
    return Cookies.remove(ACCOUNT_INFO)
}


